home *** CD-ROM | disk | FTP | other *** search
-
-
-
- DDDDLLLLSSSSYYYYMMMM((((3333CCCC)))) DDDDLLLLSSSSYYYYMMMM((((3333CCCC))))
-
-
-
- NNNNAAAAMMMMEEEE
- ddddllllssssyyyymmmm - get the address of a symbol in shared object
-
- SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
- cccccccc [ffffllllaaaagggg ...] ffffiiiilllleeee ... ----llllcccc [lllliiiibbbbrrrraaaarrrryyyy ...]
-
- ####iiiinnnncccclllluuuuddddeeee <<<<ddddllllffffccccnnnn....hhhh>>>>
-
- vvvvooooiiiidddd ****ddddllllssssyyyymmmm((((vvvvooooiiiidddd ****hhhhaaaannnnddddlllleeee,,,, ccccoooonnnnsssstttt cccchhhhaaaarrrr ****nnnnaaaammmmeeee))));;;;
-
- DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
- ddddllllssssyyyymmmm allows a process to obtain the address of a symbol defined within a
- shared object previously opened by ddddllllooooppppeeeennnn, ssssggggiiiiddddllllooooppppeeeennnn____vvvveeeerrrrssssiiiioooonnnn, or
- ssssggggiiiiddddllllaaaadddddddd. _h_a_n_d_l_e is a value returned by a call to ddddllllooooppppeeeennnn; the
- corresponding shared object must not have been closed using ddddllllcccclllloooosssseeee.
- _n_a_m_e is the symbol's name as a character string. ddddllllssssyyyymmmm searchs for the
- named symbol in all shared objects loaded automatically as a result of
- loading the object referenced by _h_a_n_d_l_e [see ddddllllooooppppeeeennnn(3)].
-
- The name search is done in the following order:
- If the _h_a_n_d_l_e is NULL, the base object is searched and then the rld-
- list of objects is searched, looking only at globally-visible DSOs.
-
- If the _h_a_n_d_l_e is not NULL, the named object is searched and then the
- library list of the DSO opened on _h_a_n_d_l_e is searched (in a pre-order
- breadth-first search of all listed DSOs).
-
- The first visible symbol with the requested name (weak or strong) is
- returned.
-
- For information on how names are generally resolved (as distinct from
- _d_l_s_y_m resolution) and on symbol visibility see the ddddllllooooppppeeeennnn "NAMESPACE
- ISSUES" section.
-
- Note that name resolution for names on the NULL _h_a_n_d_l_e is in rld-list
- order whereas for other _h_a_n_d_l_es the resolution is in library-list order.
-
- EEEEXXXXAAAAMMMMPPPPLLLLEEEESSSS
- The following example shows how one can use ddddllllooooppppeeeennnn and ddddllllssssyyyymmmm to access
- either function or data objects. For simplicity, error checking has been
- omitted.
-
- void *handle;
- int i, *iptr;
- int (*fptr)(int);
-
- /* open the needed object */
- handle = dlopen("/usr/mydir/libx.so", RTLD_LAZY);
-
- /* find address of function and data objects */
- fptr = (int (*)(int))dlsym(handle, "some_function");
-
-
-
-
- PPPPaaaaggggeeee 1111
-
-
-
-
-
-
- DDDDLLLLSSSSYYYYMMMM((((3333CCCC)))) DDDDLLLLSSSSYYYYMMMM((((3333CCCC))))
-
-
-
- iptr = (int *)dlsym(handle, "int_object");
-
- /* invoke function, passing value of integer as a parameter */
-
- i = (*fptr)(*iptr);
-
- SSSSEEEEEEEE AAAALLLLSSSSOOOO
- ddddlllleeeerrrrrrrroooorrrr(3), ddddllllooooppppeeeennnn(3), ssssggggiiiiddddllllooooppppeeeennnn____vvvveeeerrrrssssiiiioooonnnn(3), ddddllllcccclllloooosssseeee(3),
- ssssggggiiiiggggeeeettttddddssssoooovvvveeeerrrrssssiiiioooonnnn(3), ssssggggiiiiddddllllaaaadddddddd(3).
-
- DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS
- The C or C++ compiler may emit a warning similar to "warning(1048): cast
- between pointer-to-object and pointer-to-function" when casting the
- return type of ddddllllssssyyyymmmm to be a function pointer. While a cast from
- pointer-to-data to pointer-to-function is not necessarily portable to all
- systems (which is what the warning means) the cast and the resulting call
- will work fine on any system actually supporting ddddllllssssyyyymmmm. One could define
- a function
- int (*dlsymfunc(void *handle,char *name))();
- int (*dlsymfunc(void *handle,char *name))()
- {
- return (int (*)())dlsym(handle,name);
- }
- and call it instead of ddddllllssssyyyymmmm when getting function addresses: that has
- the effect of moving the warning message to a single spot in the program
- (the dlsymfunc definition) so the rest of the code does not get this
- warning.
-
- If _h_a_n_d_l_e does not refer to a valid object opened by ddddllllooooppppeeeennnn, or if the
- named symbol cannot be found within any of the objects associated with
- _h_a_n_d_l_e, ddddllllssssyyyymmmm returns NNNNUUUULLLLLLLL. More detailed diagnostic information is
- available through ddddlllleeeerrrrrrrroooorrrr.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PPPPaaaaggggeeee 2222
-
-
-
-